/*
 * ComerciosAgregarFrame.java
 *
 * Created on 16 de abril de 2008, 12:06 PM
 */
package org.remolques.registros;

import org.mybeans.Sesion;
import org.mybeans.ContribuyentesBeans;
import org.mybeans.ComerciosBeans;
 
import org.mybeans.RemolquesBeans;
import org.remolques.busquedas.RemolquesBusquedaConPlacaFrame;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

/**
 *
 * @author  avbravo
 */
public class RemolquesGeneralesModificarFrame extends javax.swing.JFrame {

    Sesion sesion;
    ContribuyentesBeans contribuyentesBeans;
    ComerciosBeans comerciosBeans;
    boolean focoRemolque = false;
    RemolquesBeans remolquesBeans;
    int IdRemolque;

    /** Creates new form ComerciosAgregarFrame */
    public RemolquesGeneralesModificarFrame() {
        initComponents();
        sesion = new Sesion();
        comerciosBeans = new ComerciosBeans();
        contribuyentesBeans = new ContribuyentesBeans();
        remolquesBeans = new RemolquesBeans();

        /*
         * Fondo
         */

        
          
         

        jPanelFondo.setOpaque(false);
        setContentPane(jPanelFondo);

        /*
         * fin del fondo
         */


        java.util.Calendar ca = java.util.Calendar.getInstance();
        java.sql.Date mydate = new java.sql.Date(ca.getTimeInMillis());
        jFormattedTextFieldFechaInscripcion.setValue(mydate);

        AutoCompleteDecorator.decorate(this.jComboBoxMesPago);
        AutoCompleteDecorator.decorate(this.jComboBoxUso);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanelFondo = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldIdRemolque = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldMarca = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldModelo = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldColor = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldCapacidad = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldChasis = new javax.swing.JTextField();
        jButtonGuardar = new javax.swing.JButton();
        jButtonLimpiar = new javax.swing.JButton();
        jButtonRegresar = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        jRadioButtonContribuyente = new javax.swing.JRadioButton();
        jRadioButtonComercio = new javax.swing.JRadioButton();
        jLabel11 = new javax.swing.JLabel();
        jTextFieldId = new javax.swing.JTextField();
        jTextFieldDueno = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jButtonBuscar = new javax.swing.JButton();
        jTextFieldPlaca = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jFormattedTextFieldFechaInscripcion = new javax.swing.JFormattedTextField();
        jComboBoxMesPago = new javax.swing.JComboBox();
        jLabel20 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jComboBoxUso = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldAnio = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldValor = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextAreaDescripcion = new javax.swing.JTextArea();
        jTextFieldLiquidacion = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jFormattedTextFieldFechaLiquidacion = new javax.swing.JFormattedTextField();
        jButtonLiquidacionHoy = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Modificar Generales de Remolques");
        addWindowFocusListener(new java.awt.event.WindowFocusListener() {
            public void windowGainedFocus(java.awt.event.WindowEvent evt) {
                formWindowGainedFocus(evt);
            }
            public void windowLostFocus(java.awt.event.WindowEvent evt) {
            }
        });

        jPanelFondo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanelFondo.setOpaque(false);

        jLabel1.setText("Numero");

        jTextFieldIdRemolque.setColumns(35);
        jTextFieldIdRemolque.setEditable(false);
        jTextFieldIdRemolque.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldIdRemolqueActionPerformed(evt);
            }
        });

        jLabel2.setText("Marca");

        jLabel3.setText("Modelo");

        jLabel6.setText("Color");

        jLabel9.setText("Capacidad");

        jLabel4.setText("Chasis");

        jTextFieldChasis.setText("no tiene");

        jButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/save.png"))); // NOI18N
        jButtonGuardar.setToolTipText("Guardar");
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jButtonLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/escoba.png"))); // NOI18N
        jButtonLimpiar.setToolTipText("Limpiar");
        jButtonLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimpiarActionPerformed(evt);
            }
        });

        jButtonRegresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/regresar.jpeg"))); // NOI18N
        jButtonRegresar.setToolTipText("Regresar");
        jButtonRegresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresarActionPerformed(evt);
            }
        });

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel8.setEnabled(false);

        jLabel21.setText("Dueño es");

        jRadioButtonContribuyente.setSelected(true);
        jRadioButtonContribuyente.setText("Contribuyente");
        jRadioButtonContribuyente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonContribuyenteMouseClicked(evt);
            }
        });

        jRadioButtonComercio.setText("Comercio");
        jRadioButtonComercio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonComercioMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jLabel21)
                .addGap(18, 18, 18)
                .addComponent(jRadioButtonContribuyente)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButtonComercio)
                .addContainerGap(164, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel21)
            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jRadioButtonComercio)
                .addComponent(jRadioButtonContribuyente))
        );

        jLabel11.setText("Identificador");

        jTextFieldId.setEditable(false);

        jTextFieldDueno.setEditable(false);

        jLabel16.setText("Dueño");

        jButtonBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/search.png"))); // NOI18N
        jButtonBuscar.setToolTipText("Buscar ");
        jButtonBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarActionPerformed(evt);
            }
        });

        jTextFieldPlaca.setColumns(35);
        jTextFieldPlaca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldPlacaActionPerformed(evt);
            }
        });

        jLabel10.setText("Placa");

        jLabel19.setText("Fecha Inscripcion");

        jFormattedTextFieldFechaInscripcion.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));
        jFormattedTextFieldFechaInscripcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedTextFieldFechaInscripcionActionPerformed(evt);
            }
        });

        jComboBoxMesPago.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }));

        jLabel20.setText("Mes Pago");

        jLabel15.setText("Uso");

        jComboBoxUso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Comercial", "Particular", "Bicicleta", "Moto", "Remolque", "Taxi", "Volquete", "Tanque", "Sin Tipo" }));

        jLabel8.setText("Año");

        jLabel12.setText("Valor");

        jLabel7.setText("Descripcion");

        jTextAreaDescripcion.setColumns(20);
        jTextAreaDescripcion.setRows(5);
        jScrollPane3.setViewportView(jTextAreaDescripcion);

        jLabel23.setText("No. Liquidacion");

        jLabel22.setText("Fecha Liquidacion");

        jFormattedTextFieldFechaLiquidacion.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/mm/yyyy"))));
        jFormattedTextFieldFechaLiquidacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedTextFieldFechaLiquidacionActionPerformed(evt);
            }
        });

        jButtonLiquidacionHoy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/hoy.png"))); // NOI18N
        jButtonLiquidacionHoy.setToolTipText("Hoy");
        jButtonLiquidacionHoy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLiquidacionHoyActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelFondoLayout = new javax.swing.GroupLayout(jPanelFondo);
        jPanelFondo.setLayout(jPanelFondoLayout);
        jPanelFondoLayout.setHorizontalGroup(
            jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFondoLayout.createSequentialGroup()
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel10))
                        .addGap(48, 48, 48)
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jTextFieldPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTextFieldIdRemolque, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(411, 411, 411))
                    .addComponent(jLabel6)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addGap(100, 100, 100)
                                .addComponent(jTextFieldColor, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel15)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel19)
                                    .addComponent(jLabel20)
                                    .addComponent(jLabel8))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldAnio, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBoxMesPago, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jFormattedTextFieldFechaInscripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBoxUso, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(26, 26, 26)
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel12)
                                    .addComponent(jLabel9))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldChasis, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldValor, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldCapacidad, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jLabel4))
                        .addGap(112, 112, 112))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addGap(54, 54, 54)
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jTextFieldMarca, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
                                .addGap(348, 348, 348))
                            .addComponent(jTextFieldModelo, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(51, 51, 51)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addGap(88, 88, 88)
                                .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonRegresar, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(3, 3, 3))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel22)
                                    .addComponent(jLabel23)))
                            .addComponent(jLabel11)
                            .addComponent(jLabel16))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldId, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldDueno, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jFormattedTextFieldFechaLiquidacion, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonLiquidacionHoy))
                            .addComponent(jTextFieldLiquidacion, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 190, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanelFondoLayout.setVerticalGroup(
            jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFondoLayout.createSequentialGroup()
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jButtonBuscar)
                    .addComponent(jTextFieldPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldIdRemolque, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldMarca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldModelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jComboBoxMesPago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldCapacidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedTextFieldFechaInscripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19))
                        .addGap(18, 18, 18)
                        .addComponent(jTextFieldAnio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jTextFieldChasis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(jLabel8)
                            .addComponent(jTextFieldValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(10, 10, 10)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jComboBoxUso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel16))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addComponent(jTextFieldId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldDueno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jFormattedTextFieldFechaLiquidacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonLiquidacionHoy)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(jTextFieldLiquidacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jButtonGuardar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonRegresar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                    .addComponent(jButtonLimpiar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelFondo, javax.swing.GroupLayout.PREFERRED_SIZE, 702, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelFondo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextFieldIdRemolqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldIdRemolqueActionPerformed
        CargarRemolques();
}//GEN-LAST:event_jTextFieldIdRemolqueActionPerformed

private void jButtonRegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresarActionPerformed

    dispose();
}//GEN-LAST:event_jButtonRegresarActionPerformed

private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed


    try {
        String Placa = this.jTextFieldPlaca.getText();

        if (Placa == null || Placa.equals("")) {
            JOptionPane.showMessageDialog(this, "Indique un numero de placa", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldPlaca.requestFocus();
            return;
        }
        String SNumero = this.jTextFieldIdRemolque.getText();

        if (SNumero == null || SNumero.equals("")) {
            JOptionPane.showMessageDialog(this, "Indique un numero de placa", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldPlaca.requestFocus();
            return;
        }
         IdRemolque = Integer.parseInt(SNumero);
        if (IdRemolque <= 0) {
            JOptionPane.showMessageDialog(this, "Seleccione un remolque", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldIdRemolque.requestFocus();
            return;
        }

        String Marca = this.jTextFieldMarca.getText();
        if (Marca == null || Marca.equals("")) {
            JOptionPane.showMessageDialog(this, "Ingrese la marca", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldMarca.requestFocus();
            return;
        }
        String Modelo = this.jTextFieldModelo.getText();
        if (Modelo == null || Modelo.equals("")) {
            JOptionPane.showMessageDialog(this, "Ingrese el modelo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldModelo.requestFocus();
            return;
        }

      
        String color = this.jTextFieldColor.getText();
        if (color == null || color.equals("")) {
            JOptionPane.showMessageDialog(this, "Ingrese el color", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldColor.requestFocus();
            return;
        }
        String capacidad = this.jTextFieldCapacidad.getText();
        if (capacidad == null || capacidad.equals("")) {
            JOptionPane.showMessageDialog(this, "Ingrese la capacidad", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldCapacidad.requestFocus();
            return;
        }
        String chasis = this.jTextFieldChasis.getText();
        if (chasis == null || chasis.equals("")) {
            JOptionPane.showMessageDialog(this, "Ingrese el numero de chasis", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldChasis.requestFocus();
            return;
        }

        String SAnio = jTextFieldAnio.getText();
        if (SAnio == null || SAnio.equals("")) {
            JOptionPane.showMessageDialog(this, "Ingrese el año", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldAnio.requestFocus();
            return;
        }
        int anio = Integer.parseInt(SAnio);
        if (anio <= 1900) {
            JOptionPane.showMessageDialog(this, "El año no es valido", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldAnio.requestFocus();
            return;
        }

        double valor;
        String SValor = jTextFieldValor.getText();
        if (SValor == null || SValor.equals("")) {
            // JOptionPane.showMessageDialog(this, "Ingrese el valor", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            // jTextFieldValor.requestFocus();
            // return;
            valor = 0;
        } else {
            valor = Double.parseDouble(SValor);
        }

        if (valor < 0) {
            JOptionPane.showMessageDialog(this, "Ingrese el valor", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jTextFieldValor.requestFocus();
            return;
        }
       
       
        String Uso = (String) this.jComboBoxUso.getSelectedItem();
        if (Uso == null || Uso.equals("")) {
            JOptionPane.showMessageDialog(this, "seleccione el uso de remolque", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        String MesPago = (String) this.jComboBoxMesPago.getSelectedItem();
        if (MesPago == null || MesPago.equals("")) {
            JOptionPane.showMessageDialog(this, "seleccione el mes de pago", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        String descripcion = this.jTextAreaDescripcion.getText();
        if (descripcion == null) {
            descripcion = "";
        }
        String sFecha = jFormattedTextFieldFechaInscripcion.getText();
        if (sFecha == null || sFecha.equals("")) {
            JOptionPane.showMessageDialog(this, "seleccione la fecha de inscripcion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            jFormattedTextFieldFechaInscripcion.requestFocus();
        }

        String Liquidacion = this.jTextFieldLiquidacion.getText();
        if (Liquidacion == null) {
            Liquidacion = "";
        }


        if (sesion.Conectar() == false) {
            JOptionPane.showMessageDialog(this, "No se pudo establecer la conexion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        String sql = "update remolques set marca =?, modelo =?, anio =?, " +
                " chasis =?, capacidad =?, valor=?, " +
                " color=?, descripcion=?,  " +
                " uso=?, liquidacion=?, fechaliquidacion=?, fechainscripcion=?, mespago=? " +
                " where idremolque= ? and placa=? and idmunicipio=? and activo='si'";


        PreparedStatement prest = sesion.con.prepareStatement(sql);

        prest.setString(1, Marca);
        prest.setString(2, Modelo);
        prest.setInt(3, anio);
        prest.setString(4, chasis);
        prest.setString(5, capacidad);
        prest.setDouble(6, valor);

        prest.setString(7, color);
        prest.setString(8, descripcion);

        prest.setString(9, Uso);
        prest.setString(10, Liquidacion);
        String sFechaLiquidacion2 = jFormattedTextFieldFechaLiquidacion.getText();
        if (sFechaLiquidacion2 == null || sFechaLiquidacion2.equals("")) {
            prest.setDate(11, null);
        } else {
            java.util.Date myFechaLiquidacion = (java.util.Date) jFormattedTextFieldFechaLiquidacion.getValue();

            java.sql.Date dateLiquidacion = new java.sql.Date(myFechaLiquidacion.getTime());
            prest.setDate(11, dateLiquidacion); //fechaliquidacion

        }
        String sFechaInscripcion = jFormattedTextFieldFechaInscripcion.getText();
        if (sFechaInscripcion == null || sFechaInscripcion.equals("")) {
            prest.setDate(12, null);
        } else {
            java.util.Date myFechaInscripcion = (java.util.Date) jFormattedTextFieldFechaInscripcion.getValue();

            java.sql.Date dateInscripcion = new java.sql.Date(myFechaInscripcion.getTime());
            prest.setDate(12, dateInscripcion); //fechaliquidacion

        }

        prest.setString(13, MesPago);

        prest.setInt(14, IdRemolque);
        prest.setString(15, Placa); //placa
        prest.setString(16, sesion.getIdmunicipio());



        int count = prest.executeUpdate();
        sesion.con.close();
        sesion.setIdRemolque(IdRemolque);
        sesion.setPlaca(Placa);
        JOptionPane.showMessageDialog(this, "Datos Generales del remolque actualizados exitosamente.", "Mensaje", JOptionPane.INFORMATION_MESSAGE);


    } catch (Exception ex) {
        System.out.println("Error" + ex);
        JOptionPane.showMessageDialog(this, "Error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}//GEN-LAST:event_jButtonGuardarActionPerformed

private void jButtonLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimpiarActionPerformed

    Limpiar();
}//GEN-LAST:event_jButtonLimpiarActionPerformed

private void jFormattedTextFieldFechaInscripcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedTextFieldFechaInscripcionActionPerformed
}//GEN-LAST:event_jFormattedTextFieldFechaInscripcionActionPerformed

private void jFormattedTextFieldFechaLiquidacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedTextFieldFechaLiquidacionActionPerformed
}//GEN-LAST:event_jFormattedTextFieldFechaLiquidacionActionPerformed

private void jButtonLiquidacionHoyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLiquidacionHoyActionPerformed

    java.util.Calendar ca = java.util.Calendar.getInstance();
    java.sql.Date mydate = new java.sql.Date(ca.getTimeInMillis());

    jFormattedTextFieldFechaLiquidacion.setValue(mydate);
}//GEN-LAST:event_jButtonLiquidacionHoyActionPerformed

private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowGainedFocus
    // TODO add your handling code here:
    try {


        if (focoRemolque) {
            Actualizar();
        }

        focoRemolque = false;
    } catch (Exception ex) {
        sesion.MostrarMensajeError("Error ", "formWindowGainedFocus()\nError " + ex.getMessage().toString());
    }
}//GEN-LAST:event_formWindowGainedFocus

private void jRadioButtonContribuyenteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonContribuyenteMouseClicked
}//GEN-LAST:event_jRadioButtonContribuyenteMouseClicked

private void jRadioButtonComercioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonComercioMouseClicked
}//GEN-LAST:event_jRadioButtonComercioMouseClicked

private void jButtonBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarActionPerformed

    RemolquesBusquedaConPlacaFrame remolquesBusquedaConPlacaFrame = new RemolquesBusquedaConPlacaFrame();
    remolquesBusquedaConPlacaFrame.setLocationRelativeTo(null);
    remolquesBusquedaConPlacaFrame.setVisible(true);
    focoRemolque = true;
}//GEN-LAST:event_jButtonBuscarActionPerformed

private void jTextFieldPlacaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPlacaActionPerformed

    CargarRemolques();
}//GEN-LAST:event_jTextFieldPlacaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new RemolquesGeneralesModificarFrame().setVisible(true);
            }
        });
    }

    private void Limpiar() {
        this.jTextFieldIdRemolque.setText("");
        this.jTextFieldMarca.setText("");
        this.jTextFieldModelo.setText("");
        this.jTextFieldColor.setText("");
        this.jTextAreaDescripcion.setText("");
        this.jTextFieldCapacidad.setText("");
        this.jTextFieldChasis.setText("");
        this.jTextFieldAnio.setText("");
        this.jTextFieldValor.setText("");
        jTextFieldId.setText("");
        jTextFieldDueno.setText("");
        jTextFieldLiquidacion.setText("");
        jFormattedTextFieldFechaLiquidacion.setText("");
        jFormattedTextFieldFechaInscripcion.setText("");

    }

    private void CargarRemolques() {


        try {
            String Placa = this.jTextFieldPlaca.getText();
            if (Placa == null || Placa.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese la placa", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }


            remolquesBeans.setPlaca(Placa);

            if (remolquesBeans.ConsultarPorPlaca() == true) {



                jTextFieldId.setText(remolquesBeans.getId());
                remolquesBeans.setTipoId(remolquesBeans.getTipoId().toLowerCase());
                if (remolquesBeans.getTipoId().equals("contribuyentes")) {
                    ContribuyentesCargar();
                    jRadioButtonContribuyente.setSelected(true);
                    jRadioButtonComercio.setSelected(false);
                } else {
                    if (remolquesBeans.getTipoId().equals("comercios")) {
                        ComerciosCargar();
                        jRadioButtonContribuyente.setSelected(false);
                        jRadioButtonComercio.setSelected(true);
                    }

                }

                Actualizar();

            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }

    private void Actualizar() {
        try {

            jTextFieldPlaca.setText(remolquesBeans.getPlaca());
            jTextFieldMarca.setText(remolquesBeans.getMarca());
            jTextFieldModelo.setText(remolquesBeans.getModelo());
            jTextFieldColor.setText(remolquesBeans.getColor());
            jTextFieldIdRemolque.setText(String.valueOf(remolquesBeans.getIdRemolque()));
            jTextFieldCapacidad.setText(remolquesBeans.getCapacidad());
            jTextFieldId.setText(remolquesBeans.getId());
            jTextFieldDueno.setText(remolquesBeans.getDueno());
            jFormattedTextFieldFechaInscripcion.setText(String.valueOf(remolquesBeans.getFechaInscripcion()));
            jTextFieldAnio.setText(String.valueOf(remolquesBeans.getAnio()));
            jTextFieldValor.setText(String.valueOf(remolquesBeans.getValor()));
jTextFieldChasis.setText(remolquesBeans.getChasis());
jTextFieldLiquidacion.setText(remolquesBeans.getLiquidacion());
            jFormattedTextFieldFechaInscripcion.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));

            jFormattedTextFieldFechaLiquidacion.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));
            jFormattedTextFieldFechaLiquidacion.setValue(remolquesBeans.getFechaLiquidacion());


            jTextAreaDescripcion.setText(remolquesBeans.getDescripcion());
            String TipoId = remolquesBeans.getTipoId();
            TipoId =
                    TipoId.toLowerCase();
            if (TipoId.equals("contribuyentes")) {
                jRadioButtonContribuyente.setSelected(true);
                jRadioButtonComercio.setSelected(false);
            } else {
                if (TipoId.equals("comercios")) {
                    jRadioButtonContribuyente.setSelected(false);
                    jRadioButtonComercio.setSelected(true);
                }

            }

           
            String Uso = remolquesBeans.getUso();
            if (Uso == null || Uso.equals("")) {
                JOptionPane.showMessageDialog(this, "seleccione el uso de remolque", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                Uso =
                        "";
            }

            this.jComboBoxUso.setSelectedItem(Uso);

            String MesPago = remolquesBeans.getMesPago();
            if (MesPago == null || MesPago.equals("")) {
                JOptionPane.showMessageDialog(this, "seleccione el mes de pago", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                MesPago =    "";
            }

            this.jComboBoxMesPago.setSelectedItem(MesPago);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }

    private void ContribuyentesCargar() {
        try {
            String cedula = this.jTextFieldId.getText();
            if (cedula == null || cedula.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese la cedula del contribuyente", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }


            if (sesion.Conectar() == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }



            String sqlquery = "select * from contribuyentes where idmunicipio = ? and cedula = ?";
            PreparedStatement psquery = sesion.con.prepareStatement(sqlquery);
            psquery.setString(1, sesion.getIdmunicipio());
            psquery.setString(2, cedula);
            ResultSet rs = psquery.executeQuery();
            rs.next();
            int x = rs.getRow();
            if (x == 0) {
                JOptionPane.showMessageDialog(this, "No existen registros de contribuyentes con esa cedula", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }


            String activo = rs.getString("activo");
            if (activo.equals("no")) {
                JOptionPane.showMessageDialog(this, "Este registro esta inactivo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }


            contribuyentesBeans.setCedula(cedula);
            contribuyentesBeans.setContribuyente(rs.getString("contribuyente"));
            contribuyentesBeans.setIdSeguroSocial(rs.getString("idsegurosocial"));
            contribuyentesBeans.setOcupacion(rs.getString("ocupacion"));
            contribuyentesBeans.setNacionalidad(rs.getString("nacionalidad"));
            contribuyentesBeans.setIdMunicipio(rs.getString("idmunicipio"));
            contribuyentesBeans.setIdCorregimiento(rs.getString("idcorregimiento"));
            contribuyentesBeans.setDomicilio(rs.getString("domicilio"));
            contribuyentesBeans.setCasa(rs.getString("casa"));
            contribuyentesBeans.setTelefono(rs.getString("telefono"));
            contribuyentesBeans.setApartadoPostal(rs.getString("apartadopostal"));
            contribuyentesBeans.setEmail(rs.getString("email"));
            contribuyentesBeans.setObservacion(rs.getString("observacion"));
            contribuyentesBeans.setIdMunicipioVive(rs.getString("idmunicipiovive"));
            contribuyentesBeans.setIdCorregimientoVive(rs.getString("idcorregimientovive"));
            contribuyentesBeans.setActivo(rs.getString("activo"));
            contribuyentesBeans.setFoto(rs.getString("foto"));



            if (contribuyentesBeans.getContribuyente() == null || contribuyentesBeans.getContribuyente().equals("")) {
                JOptionPane.showMessageDialog(this, "El contribuyente esta en blanco", "Mensaje", JOptionPane.WARNING_MESSAGE);
                return;

            }



            jTextFieldDueno.setText(contribuyentesBeans.getContribuyente());
            remolquesBeans.setDueno(contribuyentesBeans.getContribuyente());

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }

    private void ComerciosCargar() {
        try {
            String IdComercio = this.jTextFieldId.getText();
            if (IdComercio == null || IdComercio.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el codigo del comercio", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }


            if (sesion.Conectar() == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }



            String sqlquery = "select comercios.*, contribuyentes.contribuyente from comercios, contribuyentes where comercios.idmunicipio = ? and comercios.idcomercio = ? and comercios.cedula = contribuyentes.cedula";
            PreparedStatement psquery = sesion.con.prepareStatement(sqlquery);
            psquery.setString(1, sesion.getIdmunicipio());
            psquery.setString(2, IdComercio);
            ResultSet rs = psquery.executeQuery();
            rs.next();
            int x = rs.getRow();
            if (x == 0) {
                JOptionPane.showMessageDialog(this, "No existen registros de comercios con ese codigo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;

            }



            String comercio = rs.getString("comercio");
            String cedula = rs.getString("cedula");
            String contribuyente = rs.getString("contribuyente");
            String Ruc = rs.getString("ruc");
            String Descripcion = rs.getString("descripcion");
            String Direccion = rs.getString("direccion");
            String IdCorregimiento = rs.getString("idcorregimiento");
            String Telefono = rs.getString("telefono");
            String Hipotecado = rs.getString("hipotecado");
            String Bajado = rs.getString("bajado");
            String Traspaso = rs.getString("traspaso");
            String Estatal = rs.getString("estatal");
            String Secuestrado = rs.getString("secuestrado");
            String Activo = rs.getString("activo");

            jTextFieldDueno.setText(comercio);

            if (comercio == null || comercio.equals("")) {
                JOptionPane.showMessageDialog(this, "El comercio esta en blanco", "Mensaje", JOptionPane.WARNING_MESSAGE);
                return;

            }



            comerciosBeans.setIdComercio(IdComercio);
            comerciosBeans.setComercio(comercio);
            comerciosBeans.setCedula(cedula);
            comerciosBeans.setContribuyente(contribuyente);
            comerciosBeans.setRuc(Ruc);
            comerciosBeans.setDescripcion(Descripcion);
            comerciosBeans.setDireccion(Direccion);
            comerciosBeans.setIdCorregimiento(IdCorregimiento);
            comerciosBeans.setTelefono(Telefono);
            comerciosBeans.setHipotecado(Hipotecado);
            comerciosBeans.setBajado(Bajado);
            comerciosBeans.setTraspaso(Traspaso);
            comerciosBeans.setEstatal(Estatal);
            comerciosBeans.setSecuestrado(Secuestrado);
            comerciosBeans.setActivo(Activo);
            remolquesBeans.setDueno(comerciosBeans.getComercio());
            repaint();

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButtonBuscar;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonLimpiar;
    private javax.swing.JButton jButtonLiquidacionHoy;
    private javax.swing.JButton jButtonRegresar;
    private javax.swing.JComboBox jComboBoxMesPago;
    private javax.swing.JComboBox jComboBoxUso;
    private javax.swing.JFormattedTextField jFormattedTextFieldFechaInscripcion;
    private javax.swing.JFormattedTextField jFormattedTextFieldFechaLiquidacion;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanelFondo;
    private javax.swing.JRadioButton jRadioButtonComercio;
    private javax.swing.JRadioButton jRadioButtonContribuyente;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextArea jTextAreaDescripcion;
    private javax.swing.JTextField jTextFieldAnio;
    private javax.swing.JTextField jTextFieldCapacidad;
    private javax.swing.JTextField jTextFieldChasis;
    private javax.swing.JTextField jTextFieldColor;
    private javax.swing.JTextField jTextFieldDueno;
    private javax.swing.JTextField jTextFieldId;
    private javax.swing.JTextField jTextFieldIdRemolque;
    private javax.swing.JTextField jTextFieldLiquidacion;
    private javax.swing.JTextField jTextFieldMarca;
    private javax.swing.JTextField jTextFieldModelo;
    private javax.swing.JTextField jTextFieldPlaca;
    private javax.swing.JTextField jTextFieldValor;
    // End of variables declaration//GEN-END:variables
}
